package com.web.transaction.entity;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.web.currency.entity.Currency;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;

@ToString
@ApiModel
@Data
public class Transaction {
	public static final String TX_BUY = "B";
	public static final String TX_SELL = "S";

	public static DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd");

	@ApiModelProperty("dealNo")
	@Excel(name = "dealNo")
	private String dealNo;

	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
	@ApiModelProperty("tradedate")
	@Excel(name = "tradeDate")
	private LocalDate tradeDate;

	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
	@ApiModelProperty("valueDate")
	@Excel(name = "valueDate ")
	private LocalDate valueDate;

	@ApiModelProperty("excde")
	@Excel(name = "excde")
	private String excde;

	@ApiModelProperty("customerNo")
	private String customerNo;

	@ApiModelProperty("withdrawalAcct")
	private String withdrawalAcct;

	@ApiModelProperty("withdrawalCcy")
	@Excel(name = "withdrawalCcy",width = 15)
	private String withdrawalCcy;

	@ApiModelProperty("withdrawalAmt")
	@Excel(name = "withdrawalAmt",width = 15)
	private BigDecimal withdrawalAmt;

	@ApiModelProperty("depositeAcct")
	private String depositeAcct;

	@ApiModelProperty("depositeCcy")
	@Excel(name = "depositeCcy",width = 15)
	private String depositeCcy;

	@ApiModelProperty("depositedAmt")
	@Excel(name = "depositedAmt",width = 15)
	private BigDecimal depositedAmt;

	@ApiModelProperty("counterparty")
	private String counterparty;

	@ApiModelProperty("bankCode")
	private String bankCode;

	@ApiModelProperty("srcJnlNo")
	private String srcJnlNo;

	@ApiModelProperty("bankCostRate")
	@Excel(name = "bankCostRate",width = 15)
	private BigDecimal bankCostRate;

	@ApiModelProperty("bankBuyTransferAmt")
	private BigDecimal bankBuyTransferAmt;

	@ApiModelProperty("bankSellTransferAmt")
	private BigDecimal bankSellTransferAmt;

	public boolean isContainHKD() {
		return this.excde.contains(Currency.HKD);
	}

	public boolean isWithdrawalHKD() {
		return this.withdrawalCcy.equals(Currency.HKD);
	}

	public boolean isDepositeHKD() {
		return this.depositeCcy.equals(Currency.HKD);
	}
}
